#include "server.h"
#include <stdio.h>
#include <string.h>

int handle_pwd(ServerInfo* server, int client_index) {
    ClientInfo* client = &server->clients[client_index];
    Message response;

    if (client->is_logged_in) {
        response.type = MSG_TYPE_SUCCESS;
        response.length = snprintf(response.data, sizeof(response.data), "%s", client->current_dir);
    } else {
        response.type = MSG_TYPE_FAIL;
        response.length = snprintf(response.data, sizeof(response.data), "用户未登录");
    }

    if (send_message(client->socket, &response) < 0) {
        perror("发送pwd响应失败");
        return -1;
    }

    return 0;
}